package org.example.test.test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Signal {

    private static volatile Signal signal = null;

    private Signal() {

    }

    public static Signal getSignal() {
        if (signal == null) {
            synchronized (Signal.class) {
                if (signal == null) {
                    signal = new Signal();
                }
            }
        }
        return signal;
    }

    public static void main(String[] args) {
        int[] arr = {2, 2, 3, 4, 4, 6, 10, 8, 1};
        bubbleSort(arr);
    }

    public static void bubbleSort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] > array[j]){
                    int temp = array[i];
                    array[i] = array[j];
                    array[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(array));
    }

    public static int solution(int[] cards) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < cards.length; i++) {
            int card = cards[i];
            if (map.containsKey(card)) {
                map.remove(card);
            }else {
                map.put(card, 1);
            }
        }
        Set<Map.Entry<Integer, Integer>> entries = map.entrySet();
        Integer key = null;
        for (Map.Entry<Integer, Integer> entry : entries) {
            key = entry.getKey();
        }
        return key;
    }
}
